<template>
  <!-- 模块：刷新按钮 -->
  <view>
    <view style="margin: 30rpx">
      <up-button type="success" @click="refresh">
        <up-icon label=" " size="21" name="reload" color="white"></up-icon>
        刷新
      </up-button>
    </view>
  </view>
  <!-- 模块：刷新按钮结束 -->

  <!-- 模块：提示信息 -->
  <view style="margin: 0 30rpx;color: #ff5c26;font-size: 30rpx;font-weight: bold">
    小红书app发布笔记必须间隔1小时以上才合格。如果您只是多次获取从中挑选一个满意的文案发布，并不受此影响!
  </view>
  <!-- 模块：提示信息结束 -->

  <!-- 模块：标题展示 -->
  <view class="copy" style="text-align: center">
    {{ mediaData?.title }}
  </view>
  <view style="margin: 30rpx">
    <up-button type="primary" @click="copyContent(mediaData?.title)">复制标题</up-button>
  </view>
  <!-- 模块：标题展示结束 -->

  <!-- 模块：正文展示 -->
  <view class="copy">
    {{ mediaData?.content }}
  </view>
  <view style="margin: 30rpx">
    <up-button type="primary" @click="copyContent(mediaData?.content)">复制正文</up-button>
  </view>
  <!-- 模块：正文展示结束 -->

  <!-- 模块：自评展示 -->
  <view class="copy" style="text-align: center;min-height: 60rpx">
    {{ mediaData?.comment }}
  </view>
  <view style="margin: 30rpx">
    <up-button type="primary" @click="copyContent(mediaData?.comment)">复制自评</up-button>
  </view>
  <!-- 模块：自评展示结束 -->

  <!-- 模块：图片保存提示 -->
  <view style="margin: 0 30rpx;color: #ff5c26;font-size: 30rpx;font-weight: bold;text-align: center">
    长按图片保存，请选择精美实物图作为首图
  </view>
  <view class="novice">
    <image show-menu-by-longpress :src="mediaData?.img" mode="widthFix">
    </image>
  </view>
  <!-- 模块：图片保存提示结束 -->

  <!-- 模块：底部安全区域 -->
  <view style="height: 100rpx"></view>
  <up-safe-bottom></up-safe-bottom>
  <!-- 模块：底部安全区域结束 -->
</template>
<script setup>
import {ref} from "vue";
import {onLoad} from "@dcloudio/uni-app";
import {getMarketingXhsAPI} from "../services/me";
import {BaseURL} from "../utils/lshttp";

const mediaData =ref();
const copyContent = (content) => {
  uni.showLoading({title: '正在复制'})
  uni.setClipboardData({
    data: content,
    success() {
      uni.showToast({title: "复制成功", icon: 'success'})
    }
  })
}
const refresh = async () => {
  await uni.showLoading({title: "正在加载"})

  const res = await getMarketingXhsAPI({id:mediaData.value?mediaData.value.id:''})
  mediaData.value = res.result
  mediaData.value.img = BaseURL + mediaData.value.img
  console.log('mediaData.value',mediaData.value)
}
const toCourse = () => {
  uni.navigateTo({url: '/challenge/publish_help'})
}
onLoad(()=>{
  refresh()
})
</script>


<style lang="scss">
page {
  background-color: #F3F4F5;
}

.copy {
  background-color: white;
  margin: 30rpx 30rpx 0;
  padding: 20rpx;
  border-radius: 10rpx;
}

.novice image {
  width: 92%;
  height: auto;
  margin: 20rpx 4% 20rpx;
  vertical-align: bottom;
  border-radius: 20rpx;
}
</style>